package Model;

import java.util.ArrayList;

/**
 * Aggregates Event occurrences 
 * @author Yury Kitaev
 *
 */
public class Catalog 
{
	private ArrayList<Event> events;
	
	public Catalog()
	{
		events = new ArrayList<Event>();
	}

	public ArrayList<Event> getEvents() 
	{
		return events;
	}

	public void setEvents(ArrayList<Event> events) 
	{
		this.events = events;
	}	
	
	/**
	 * Returns list of events.
	 * @param onlyOpen True if you would like to exclude closed events
	 * @return List of events
	 */
	public ArrayList<Event> getEvents(boolean onlyOpen)
	{
		if (onlyOpen)
		{
			ArrayList<Event> onlyOpenEvents = new ArrayList<Event>(events.size());
			for (Event e : events)
			{
				if (EventStatus.Open == e.getStatus())
				{
					onlyOpenEvents.add(e);
				}
			}
			return onlyOpenEvents;
		}
		else
		{
			return getEvents();
		}
	}
}
